package com.tz.crm.service.impl;

import com.tz.crm.dao.ContractDao;
import com.tz.crm.dao.CustomerDao;
import com.tz.crm.dao.PaymentDao;
import com.tz.crm.dao.VisitRecordDao;
import com.tz.crm.entity.IndexPicture;
import com.tz.crm.service.IndexDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 首页报表数据
 */
@Service
@Transactional
public class IndexDataServiceImpl implements IndexDataService {
    @Autowired
    private CustomerDao customerDao;
    @Autowired
    private VisitRecordDao visitRecordDao;
    @Autowired
    private ContractDao contractDao;
    @Autowired
    private PaymentDao paymentDao;

    @Override
    public Object getData(String view, int month) {
        Object obj = null;
        switch (view){
            case "countNewCustomer":
                obj = customerDao.getCountNewCustomer(month);
                break;
            case "countVisit":
                obj = visitRecordDao.getCount(month);
                break;
            case "sumSigned":
                obj = contractDao.getSumMoney(month);
                break;
            case "sumPaid":
                obj = paymentDao.getSumPaidMoney(month);
                break;
            case "sumUnpaid":
                obj = paymentDao.getSumUnpaidMoney(month);
                break;
            default:
                break;
        }
        return obj;
    }
}
